package com.uenpay.im.ui.old.activity.attendance;

import com.uenpay.im.configuration.APIConfiguration;
import com.uenpay.im.entities.HttpInvokeResult;
import com.uenpay.im.invokeitems.BaseHttpInvokeItem;

import org.json.JSONException;
import org.json.JSONObject;

/**
 * @author SL
 * @created 2016-3-21 14:33:16
 * @copyRight http://www.qiyunxin.com
 * @function 设置签到时间
 */
public class SetTimeTableInvokeItem extends BaseHttpInvokeItem {

	public class SetTimeTableInvokeItemResult extends HttpInvokeResult {

	}

	public SetTimeTableInvokeItemResult getOutPut() {
		return (SetTimeTableInvokeItemResult) GetResultObject();
	}

	public SetTimeTableInvokeItem(int entid, String startTime, String endTime,
			String latitude, String longitude) {
		String url = APIConfiguration.getBaseUrl()
				+ "Oa/Attendance/setTimeTable?entid=" + entid + "&starttime="
				+ startTime + "&endtime=" + endTime + "&longitude=" + longitude
				+ "&latitude=" + latitude + "&"
				+ APIConfiguration.getCustIdAndToken();
		SetUrl(url);
	}

	@Override
	protected Object DeserializeResult(String responseBody) {
		SetTimeTableInvokeItemResult result = new SetTimeTableInvokeItemResult();
		try {
			JSONObject json = new JSONObject(responseBody);
			result.status = json.optInt("status");
			result.msg = json.optString("msg");
		} catch (JSONException e) {
			e.printStackTrace();
			return result;
		}

		return result;
	}

}
